<include file="Public/header" />
<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 邀请码管理 <span class="c-gray en">&gt;</span> 邀请码 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">

	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<form class="formleft" name="" id="" action="__URL__/baseconfig/" method="get">
			<input class="input-text" style="width:200px" type="text" value="<{$_GET['code']}>" placeholder="邀请码" name="code">
			<input class="input-text" style="width:200px" type="text" value="<{$_GET['come_from']}>" placeholder="来源" name="come_from">
			<button type="submit" class="btn btn-success"><i class="icon-plus"></i> 查询</button>
			<a href="javascript:;" onclick="make_code()" class="btn btn-primary radius"><i class="Hui-iconfont"></i> 生成邀请码</a>
			<a href="javascript:;" onclick="delAll()" class="btn btn-danger radius">批量删除</a>
			<a href="javascript:;" onclick="setStatus(0)" class="btn btn-primary radius">未启用</a>
			<a href="javascript:;" onclick="setStatus(1)" class="btn btn-primary radius">启用</a>
			<a href="javascript:;" onclick="setStatus(2)" class="btn btn-primary radius">过期</a>
			
		</form>
		<span class="r">共有数据：<strong><{$count}></strong> 条</span> 
    </div>
	
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="15">邀请码列表</th>
			</tr>
			<tr class="text-c">
				<th width="25" class="sorting_disabled" rowspan="1" colspan="1" aria-label="" style="width: 25px;"><input type="checkbox" name="" value=""></th>
				<th>序号</th>
				<th width="">邀请码</th>
				<th width="">注册数量</th>
				<th width="">来源</th>
				<th width="">状态</th>
				<th width="">添加时间</th>
				<th width="">操作</th>
			</tr>
		</thead>
		<tbody>
			<volist name="list" id="vo">
			<tr class="text-c">
				<td><input type="checkbox" value="<{$vo.id}>" name="" class="ids"></td>
				<td><{$i}></td>
				<td><{$vo.code}></td>
				<td><{$vo.nums}></td>
				<td><{$vo.come_from}></td>
				<td>
				<if condition="$vo.status eq 0">
					未启用
				</if>
				<if condition="$vo.status eq 1">
					启用
				</if>
				<if condition="$vo.status eq 2">
					已过期
				</if>
				</td>
				<td><{$vo.add_time|date="Y-m-d H:i:s",###}></td>
				<td>
				<a href="javascript:;" onclick="edit_code(<{$vo.id}>)" class="">编辑</a>
				<a title="删除" href="javascript:;" onclick="admin_del('__URL__/del/','<{$vo.id}>')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a>
				</td>
			</tr>
			</volist>
		</tbody>
	</table>
	<div class="page mt" style="text-align:right"><{$page}></div>
</div>
<script>
	//添加
	function make_code(){
		layer.prompt({
			title: '输入数量', formType: 3
		},function(pass,index){
			$.ajax({
				type: 'POST',
				data: {nums:pass},
				url: "<{:U('make_code')}>",
				success:function(data){
					if(data.status==1){	//检查通过，跳转生成波次单页面
						layer.msg(data.info,function(){
							window.location.reload();
						});
					}else{			//检查未通过，刷新页面
						layer.msg(data.info);
					}
					return false;
				}
			})
		})
	}
	//编辑
	function edit_code(id){
		layer.prompt({
			title: '输入来源', formType: 3
		},function(pass,index){
			$.ajax({
				type: 'POST',
				data: {come_from:pass,id:id},
				url: "<{:U('edit_code')}>",
				success:function(data){
					if(data.status==1){	//检查通过，跳转生成波次单页面
						layer.msg(data.info,function(){
							window.location.reload();
						});
					}else{			//检查未通过，刷新页面
						layer.msg(data.info);
					}
					return false;
				}
			})
		})
	}
	//设置属性
	function setStatus(value){
		var option = $(".ids");
		var checked_counts=0;
		var check_val = [];
        for(var i=0;i<option.length;i++){
			if(option[i].checked){
				checked_counts++;
				check_val.push(option[i].value);
			}
		}
		if(checked_counts==0){
			layer.msg('请选择内容');
			return false;
		}else{
			$.ajax({
				type: 'POST',
				data: {value:value,ids:check_val},
				url: "<{:U('setStatus')}>",
				success:function(data){
					if(data.status==1){	//检查通过，跳转生成波次单页面
						layer.msg(data.info,function(){
							window.location.reload();
						});
					}else{			//检查未通过，刷新页面
						layer.msg(data.info);
					}
					return false;
				}
			})
		}
	}
	//批量删除
	function delAll(){
		var option = $(".ids");
		var checked_counts=0;
		var check_val = [];
        for(var i=0;i<option.length;i++){
			if(option[i].checked){
				checked_counts++;
				check_val.push(option[i].value);
			}
		}
		if(checked_counts==0){
			layer.msg('请选择内容');
			return false;
		}else{
			$.ajax({
				type: 'POST',
				data: {ids:check_val},
				url: "<{:U('delAll')}>",
				success:function(data){
					if(data.status==1){	//检查通过，跳转生成波次单页面
						layer.msg(data.info,function(){
							window.location.reload();
						});
					}else{			//检查未通过，刷新页面
						layer.msg(data.info);
					}
					return false;
				}
			})
		}
	}
</script>
 <include file="Public/footer" />
<include file="Public/footer_js" />
</body>
</html>